﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebApplication1
{
    public partial class Login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Response.Write("新的一天保持美好的心情");
            }
        }


        //登录按钮
        protected void Button1_Click(object sender, EventArgs e)
        {

            var username = TextBox1.Text.Trim();
            var password = TextBox2 .Text.Trim();

            var sql = string.Format("select * From users where username = '{0}' and password = '{1}'", username, password);
            var dt = Dbhelper.table(sql);
            if (dt.Rows.Count == 1)
            {
                var row = dt.Rows[0];
                var IsActived = (bool)row.ItemArray[3];
                var IsDeleted = (bool)row.ItemArray[4];
                if (IsDeleted)
                {
                    Label3 .Text = "当前的账号已经删除或注销 如有疑问请联系客服！";

                }
                else
                {
                    if (IsActived)
                    {
                        Response.Redirect("Default.aspx");
                    }
                    else
                    {
                        Label3.Text = "当前账号已经停用 如有疑问请联系客服!";
                    }
                }
            }
            else
            {
                Label3.Text = "请输入正确的账号密码";
            }

        }

        //注册按钮
        protected void Button2_Click(object sender, EventArgs e)
        {
            Response.Redirect("About.aspx");
        }


    }



}
